package cryptography.asymmetric.RSA;

import java.security.KeyPair;
import java.security.KeyPairGenerator;
import java.security.MessageDigest;
import java.security.SecureRandom;
import java.security.Security;
import java.security.Signature;

import javax.crypto.Cipher;

public class RSACryptographyWithSignature {
//
//	public static void main(String[] args) throws Exception {
//		Security.addProvider(new org.bouncycastle.jce.provider.BouncyCastleProvider());
//
//		Security.addProvider(new org.bouncycastle.jce.provider.BouncyCastleProvider());
//
//	    KeyPairGenerator keyGen = KeyPairGenerator.getInstance("RSA", "BC");
//
//	    keyGen.initialize(512, new SecureRandom());
//
//	    KeyPair keyPair = keyGen.generateKeyPair();
//	    Signature signature = Signature.getInstance("SHA1withRSA", "BC");
//
//	    signature.initSign(keyPair.getPrivate(), new SecureRandom());
//
//	    byte[] message = "abc".getBytes();
//	    signature.update(message);
//
//	    byte[] sigBytes = signature.sign();
//	    signature.initVerify(keyPair.getPublic());
//	    signature.update("abc".getBytes());
//	    System.out.println(signature.verify(sigBytes));
//
//	}
//
//	private static String bytes2String(byte[] bytes) {
//		StringBuilder string = new StringBuilder();
//		for (byte b : bytes) {
//			String hexString = Integer.toHexString(0x00FF & b);
//			string.append(hexString.length() == 1 ? "0" + hexString : hexString);
//		}
//		return string.toString();
//	}
}
